<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #box {
        box-sizing: content-box;
        border: 1rem solid rosybrown;
        padding: 20px;
        width: 300px;
        height: 300px;
        background: rgb(134, 134, 125);
        background-clip: content-box;
        overflow: auto;
      }

      p {
        height: 150px;
        width: 400px;
        font-size: 2rem;
        border: solid;
        margin: 10px;
      }
    </style>
  </head>
  <body>
    <div id="box">
      <p>p1</p>
      <p>p2</p>
      <p>p3</p>
      <p>p4</p>
    </div>
    <script>
      const box = document.getElementById("box");
      // 判断是否滚动到底部（触底）
      setTimeout(() => {
        console.log(box.scrollHeight - box.clientHeight - box.scrollTop < 20);
      }, 3000);
    </script>
  </body>
</html>
